<?php
require_once dirname(dirname(__FILE__)) . '/shared/config/config.php';
require_once DOCUMENT_ROOT . DIR_SHARED_API . 'api_booking.php';
?>
<div class="four wide column">
                            <h1>Book Tickets</h1>
                            <form name="form_book_ticket" id="form_book_ticket" method="POST" action="tickets_quantity.php">
                                <?php if (!empty($error_show)) { ?>
                                    <div class="ui error message">
                                        <i class="close icon"></i>
                                        <div class="header">
                                            <?php echo $error_show; ?>
                                        </div>
                                    </div>
                                    <?php
                                }
                                ?>
                                
                                <div class="ui orange form segment"> 
                                    
                                    <div id="city-filter" class="field">
                                        <label>City</label>
                                        <?php
                                        $list = api_booking::get_all_cities_by_filter(0); 

                                        ?>
                                        <div class="ui fluid selection dropdown">
                                            <div class="text">--Not Selected--</div>
                                            <i class="dropdown icon"></i>
                                            <input name="ddl_city" onchange="filter_change_for_city()" type="hidden">
                                            <div class="menu ui transition hidden">
                                                <div class="item" data-value="0">--Not Selected--</div>
                                                <?php
                                                foreach ($list as $item) {
                                                ?>
                                                <div class="item" data-value="<?php echo $item['id']; ?>"><?php echo $item['name']; ?></div>
                                                <?php
                                                }?>
                                            </div>
                                        </div>
                                    </div>
                                    
                                    <script type="text/javascript">
                                        function filter_change_for_city() {
                                            
                                            $('#txt_tickets_quantity').val(0);
                                            
                                            $.ajax({
                                                type: "POST",
                                                url: "<?php echo LINK_ROOT . DIR_AJAX; ?>load_movie_filter.php",
                                                data: "empty_load=1",
                                                success: function (result) {
                                                    $("#movie-filter").html(result);
                                                }
                                            });
                                            
                                            $.ajax({
                                                type: "POST",
                                                url: "<?php echo LINK_ROOT . DIR_AJAX; ?>load_show_date_filter.php",
                                                data: "empty_load=1",
                                                success: function (result) {
                                                    $("#show-date-filter").html(result);
                                                }
                                            });
                                            
//                                            var ticket_quantity = $('#txt_tickets_quantity').val();
                                            var city_id = $("input[type='hidden'][name='ddl_city']").val();
                                            $.ajax({
                                                type: "POST",
                                                url: "<?php echo LINK_ROOT . DIR_AJAX; ?>load_movie_filter.php",
                                                data: "&city_id=" + city_id,
                                                success: function (result) {
                                                    $("#movie-filter").html(result);
                                                }
                                            });
                                            
                                            
                                            
                                        }
                                    </script>
                                    
                                    <div class="field">
                                        <label>Tickets Quantity</label>
                                        <div class="ui left icon input" style="padding: 0">
                                            <input name="txt_tickets_quantity" onchange="filter_change_for_quantity()" value="" id="txt_tickets_quantity" type="text" placeholder="0">
                                            <i class="inverted ticket icon"></i>
                                        </div>
                                    </div>
                                    
                                    
                                    <script type="text/javascript">
                                        function filter_change_for_quantity() {
                                            
                                            $.ajax({
                                                type: "POST",
                                                url: "<?php echo LINK_ROOT . DIR_AJAX; ?>load_movie_filter.php",
                                                data: "empty_load=1",
                                                success: function (result) {
                                                    $("#movie-filter").html(result);
                                                }
                                            });
                                            
                                            $.ajax({
                                                type: "POST",
                                                url: "<?php echo LINK_ROOT . DIR_AJAX; ?>load_show_date_filter.php",
                                                data: "empty_load=1",
                                                success: function (result) {
                                                    $("#show-date-filter").html(result);
                                                }
                                            });
                                            
                                            
                                            var city_id = $("input[type='hidden'][name='ddl_city']").val();
                                            var ticket_quantity = $('#txt_tickets_quantity').val();
                                            $.ajax({
                                                type: "POST",
                                                url: "<?php echo LINK_ROOT . DIR_AJAX; ?>load_movie_filter.php",
                                                data: "ticket_quantity=" + ticket_quantity
                                                    + "&city_id=" + city_id,
                                                success: function (result) {
                                                    $("#movie-filter").html(result);
                                                }
                                            });
                                        }
                                        
                                        
                                    </script>
                                    
                                    <div id="movie-filter" class="field">
                                        <label>Movie</label>
                                        <div class="ui fluid selection dropdown">
                                            <div class="text">--Not Selected--</div>
                                            <i class="dropdown icon"></i>
                                            <input name="ddl_movie" type="hidden" value="0">
                                            <div class="menu">
                                                <div class="item" data-value="0">--Not Selected--</div>
                                            </div>
                                        </div>
                                    </div>

                                    
                                    <script type="text/javascript">
                                        function filter_change_for_movie() {
                                            
                                            $.ajax({
                                                type: "POST",
                                                url: "<?php echo LINK_ROOT . DIR_AJAX; ?>load_show_date_filter.php",
                                                data: "empty_load=1",
                                                success: function (result) {
                                                    $("#show-date-filter").html(result);
                                                }
                                            });
                                            
                                            
                                            var ticket_quantity = $('#txt_tickets_quantity').val();
                                            var city_id = $("input[type='hidden'][name='ddl_city']").val();
//                                            var cinema_id = $("input[type='hidden'][name='ddl_cinema']").val();
                                            var movie_id = $("input[type='hidden'][name='ddl_movie']").val();
                                            $.ajax({
                                                type: "POST",
                                                url: "<?php echo LINK_ROOT . DIR_AJAX; ?>load_show_date_filter.php",
                                                data: "ticket_quantity=" + ticket_quantity
                                                    + "&city_id=" + city_id
//                                                    + "&cinema_id=" + cinema_id
                                                    + "&movie_id=" + movie_id,
                                                success: function (result) {
                                                    $("#show-date-filter").html(result);
                                                }
                                            });
                                        }
                                    </script>
                                    
                                    <div id="show-date-filter" class="field">
                                        <label>Show Date</label>
                                        <div class="ui fluid selection dropdown">
                                            <div class="text">--Not Selected--</div>
                                            <i class="dropdown icon"></i>
                                            <input name="ddl_show_date" type="hidden" value="0">
                                            <div class="menu">
                                                <div class="item" data-value="0">--Not Selected--</div>
                                            </div>
                                        </div>
                                    </div>
                                    
                                    
<!--                                    <script type="text/javascript">
                                        function filter_change_for_cinema() {
                                            var ticket_quantity = $('#txt_tickets_quantity').val();
                                            var city_id = $("input[type='hidden'][name='ddl_city']").val();
                                            var cinema_id = $("input[type='hidden'][name='ddl_cinema']").val();
                                            $.ajax({
                                                type: "POST",
                                                url: "<?php echo LINK_ROOT . DIR_AJAX; ?>load_movie_filter.php",
                                                data: "ticket_quantity=" + ticket_quantity
                                                    + "&city_id=" + city_id
                                                    + "&cinema_id=" + cinema_id,
                                                success: function (result) {
                                                    $("#movie-filter").html(result);
                                                }
                                            });
                                        }
                                    </script>-->
                                    
                                    

                                    
                                    
<!--                                    <script type="text/javascript">
                                        function filter_change_for_show_date() {
                                            var ticket_quantity = $('#txt_tickets_quantity').val();
                                            var city_id = $("input[type='hidden'][name='ddl_city']").val();
                                            var cinema_id = $("input[type='hidden'][name='ddl_cinema']").val();
                                            var movie_id = $("input[type='hidden'][name='ddl_movie']").val();
                                            var show_date = $("input[type='hidden'][name='ddl_show_date']").val();
                                            $.ajax({
                                                type: "POST",
                                                url: "<?php echo LINK_ROOT . DIR_AJAX; ?>load_time_start_filter.php",
                                                data: "ticket_quantity=" + ticket_quantity
                                                    + "&city_id=" + city_id
                                                    + "&cinema_id=" + cinema_id
                                                    + "&movie_id=" + movie_id
                                                    + "&show_date=" + show_date,
                                                success: function (result) {
                                                    $("#time-start-filter").html(result);
                                                }
                                            });
                                        }
                                    </script>-->


                                    <div class="ts-center">
                                        <div onclick="submit_book_data();" class="large animated fade ui orange button">
                                            <div class="visible content">Book Now</div>
                                            <div class="hidden content"><i class="ok sign icon"></i></div>
                                        </div>
                                    </div>
                                </div>
                            </form>
                        </div>